using System.Collections;
using UnityEngine;

public class RandomEventCity:MonoSingleton<RandomEventCity>
{
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    public enum events{
        breeze1,breeze2
    }
    public events? nowEvent;
    public float breezeSpeed;
    float randomTime;
    void Start()
    {
        LevelManager.I.OnSectionPassed+=GetNewEvent;
    }
    IEnumerator Wait()
    {
        yield return new WaitForSeconds(randomTime);
        LevelManager.I.speedByEvents=0;
        nowEvent=null;
    }
    public void GetNewEvent()
    {
        int random=Random.Range(1,5);
        randomTime=Random.Range(5f,10f);
        if(random==1)
        {
            nowEvent=events.breeze1;
            LevelManager.I.speedByEvents=breezeSpeed;
            StartCoroutine(Wait());
        }
        if(random==2)
        {
            nowEvent=events.breeze2;
            LevelManager.I.speedByEvents=-breezeSpeed;
            StartCoroutine(Wait());
        }

    }
    // Update is called once per frame
    void Update()
    {
        
    }
}
